package com.ai.mapper.provider;

import com.ai.bo.InterviewRecordBO;
import org.apache.ibatis.jdbc.SQL;

public class CandidateProvider {
    public String getCandidateList(InterviewRecordBO interviewRecordBO){
        return new SQL(){{
            SELECT("c.id as candidateId,c.real_name as realName, c.identity_num as identityNum,c.sex as sex,c.mobile as mobile,c.email as email,c.birthday as birthday,j.id as jobId,j.job_name as jobName ,c.create_time as createTime");
            FROM("candidate c LEFT JOIN job j ON c.job_id = j.id");
            if(interviewRecordBO.getRealName() != null && !interviewRecordBO.getRealName().trim().isEmpty()){
                WHERE("c.real_name LIKE CONCAT('%',#{realName},'%')");
            }
            if(interviewRecordBO.getMobile() != null && !interviewRecordBO.getMobile().trim().isEmpty()){
                WHERE("c.mobile LIKE CONCAT('%', #{mobile}, '%')");
            }
        }}.toString();
    }
}
